package cn.lingyangwl.agile.pay.pay.controller.scanimg;

import cn.lingyangwl.agile.common.security.annotation.Anonymous;
import cn.lingyangwl.agile.pay.common.utils.PayUtils;
import cn.lingyangwl.agile.pay.common.utils.QRCodeUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * 扫描图片生成器
 */
@RestController
@Anonymous
@RequestMapping("/scan")
public class ScanImgControllerPay  {

    /**
     * 图片地址信息
     */
    @RequestMapping("/imgs/{aesStr}.png")
    public void qrImgs(@PathVariable("aesStr") String aesStr,
                       @RequestParam(value = "width", defaultValue = "200") Integer width,
                       @RequestParam(value = "height", defaultValue = "200") Integer height,
                       HttpServletResponse response) throws Exception {
        String str = PayUtils.aesDecode(aesStr);
        QRCodeUtils.createCodeToOutputStream(str, response.getOutputStream(), width, height);
    }
}
